//
//  ZHIBOCell.swift
//  FirstSwiftProduct
//
//  Created by 范泽华 on 2017/11/6.
//  Copyright © 2017年 范泽华. All rights reserved.
//

import UIKit

class ZHIBOCell: UITableViewCell {

    var imagehead : UIImageView!
    
    
    @IBOutlet weak var zhibiLabel: UILabel!
    @IBOutlet weak var userImage: UIImageView!
    @IBOutlet weak var tags: UILabel!
    @IBOutlet weak var userNumber: UILabel!
    @IBOutlet weak var userName: UILabel!
    @IBOutlet weak var headImage: UIImageView!{
        get {
            return imagehead
        }
        set {
            imagehead = newValue
            imagehead.image = imagehead.image?.drawRectWithCorner(radius: 45/2, imageView: imagehead)
        }
    }
//    var <#variable name#>: <#type#> {
//        get {
//            <#statements#>
//        }
//        set {
//            <#variable name#> = newValue
//        }
//    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
//        headImage.image = headImage.image?.drawRectWithCorner(radius: 45/2, imageView: headImage)
    }
    
    public func configWithModel(model:livess) -> Void {
        
        userName.text = model.creator?.nick
        userNumber.text = model.online_users
        
        userImage.sd_setImage(with: URL.init(string: (model.creator?.portrait)!), placeholderImage: UIImage.init(named: " "), options: .retryFailed) { (image, error, cacheType, url) in
            
        }
        
        
        headImage.sd_setImage(with: URL.init(string: (model.creator?.portrait)!), placeholderImage: UIImage.init(named: " "), options: .retryFailed) { (image, error, cacheType, url) in
            self.headImage.image = self.headImage.image?.drawRectWithCorner(radius: 45/2, imageView: self.headImage)

        }
        
    }
    override func layoutSubviews() {
        super.layoutSubviews()
//        headImage.layer.cornerRadius = 45/2
//        headImage.layer.masksToBounds = true
//        
//        headImage.image = headImage.image?.drawRectWithCorner(radius: 45/2, imageView: headImage)
//        zhibiLabel.layer.width = 1;
        zhibiLabel.layer.borderWidth = 1
        zhibiLabel.layer.borderColor = UIColor.white.cgColor
        zhibiLabel.layer.cornerRadius = 10
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
